<template>
  <div>
    <!-- --------------------------------------列表页 -->
    <el-table :data="Examinfo" border fit highlight-current-row>
      <el-table-column label="题目ID" width="100">
        <template slot-scope="scope">
          {{ scope.row.choiceId }}
        </template>
      </el-table-column>

      <!-- <el-table-column label="类型">
        <template slot-scope="scope">
          {{ scope.row.type }}
        </template>
      </el-table-column> -->

      <el-table-column label="考试问题">
        <template slot-scope="scope">
          {{ scope.row.question }}
        </template>
      </el-table-column>

      <el-table-column label="考试选项">
        <template slot-scope="scope">
          <span>A.{{ scope.row.choicea }}</span>
          <tr>
            B.{{
              scope.row.choiceb
            }}
          </tr>
          <tr>
            C.{{
              scope.row.choicec
            }}
          </tr>
          <tr>
            D.{{
              scope.row.choiced
            }}
          </tr>
        </template>
      </el-table-column>

      <el-table-column label="正确答案">
        <template slot-scope="scope">
          <p style="color: #039e2a">
            <span v-if="scope.row.rightAnswer == 1"
              >A.{{ scope.row.choicea }}</span
            >
            <span v-if="scope.row.rightAnswer == 2"
              >B.{{ scope.row.choiceb }}</span
            >
            <span v-if="scope.row.rightAnswer == 3"
              >C.{{ scope.row.choicec }}</span
            >
            <span v-if="scope.row.rightAnswer == 4"
              >D.{{ scope.row.choiced }}</span
            >
          </p>
        </template>
      </el-table-column>
    </el-table>
    <!-- --------------------------------------- -->
    <!-- ----------------------------------分页 -->
    <div class="block" style="float: right; margin-top: 20px">
      <!-- <span class="demonstration">显示总数</span> -->
      <el-pagination
        background
        @current-change="fetchData"
        :current-page.sync="page_num"
        :page-size="page_size"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
    <!-- --------------------------------------- -->
  </div>
</template>
<script>
import healexam from "@/api/healthyarticle";
export default {
  data() {
    return {
      Examinfo:[],
       page_num: 1,
      page_size: 8, //每8个数据一页
      total: 1, //初始化
    }
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      var id = this.$route.params.examId;
      console.log("2135464213", id,this.page_num, this.page_size);
      var vm = this;
      healexam.infoexam(id,this.page_num, this.page_size).then(function (resp) {
        vm.Examinfo = resp.data.choiceList;
      });
    },
  },
};
</script>
